package com.example.demo.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.demo.bean.User;
import com.example.demo.service.UserService;
import com.example.demo.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;
import com.example.demo.mapper.UserMapper;

/**
* @author lenovo
* @description 针对表【user】的数据库操作Service实现
* @createDate 2024-09-20 16:02:26
*/
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User>
    implements UserService{

    @Autowired
    private UserMapper userMapper;


    @Override
    public  String register( User user) {

        User newUser = new User();
        newUser.setName(user.getName());
        User exist = userMapper.selectOne(new QueryWrapper<User>(newUser));
        if(exist != null){
            return "exist";
        }
        int num = userMapper.insert(user);
        if(num > 0 ){
            return "success";
        }
        return "error";

    }

}




